// 引入UI组件
import CountUI from '../../components/Count'

// 引入connect方法用于连接容器组件和UI组件
import {connect} from 'react-redux'

// 引入action
import {createIncrementAction, createDecrementAction, createIncrementAsyncAction} from '../../redux/count_action'

// a函数的返回值作为状态传递给UI组件
function mapStateToProps (state) {
  return {count: state}
}

// b函数的返回值作为操作状态的方法传递给UI组件
function mapDispatchToProps (dispatch) {
  return {
    jia: (number) => {
      dispatch (createIncrementAction (number))
    },
    jian: number => dispatch (createDecrementAction (number)), 
    asyncJia: (number, time) => dispatch (createIncrementAsyncAction (number, time)), 
  }
}

// 创建并暴露count容器组件
export default  connect(mapStateToProps, mapDispatchToProps)(CountUI)